/*
 * @Author: tianlun
 * @Date: 2021-09-07 11:02:52
 * @LastEditTime: 2021-09-16 15:19:47
 */
import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
import router from './router'

import App from './App'
import '@/projects/index/styles/index.scss' // global css
import './permission' // permission control
Vue.use(router)
Vue.use(Vuex)
// Vue.use(Element)

Vue.config.productionTip = false

const startApp = () => {
  axios.defaults.withCredentials = false
  axios.get('./static/config.json').then((res) => {
    const envParam = res.data.ENV_CONFIG[process.env.NODE_ENV].ENV_LIST
    if (envParam) {
      const { description, ...otherParam } = envParam
      // 需要拼接当前ip端口的值
      const AddOriginPathList = ['VUE_APP_ONEMAP_URL']
      Object.keys(otherParam || {}).forEach((key) => {
        if (AddOriginPathList.includes(key)) {
          // 一张图地址
          Vue.prototype[key] = window.location.origin + envParam[key]
        } else {
          Vue.prototype[key] = otherParam[key]
        }
      })
    }

    new Vue({
      el: '#app',
      router,
      render: (h) => h(App)
    })
  })
}

startApp()
